#!/bin/bash

SOURCE_DIR=$1
BACKUP_DIR=$2

if [ ! -d "$SOURCE_DIR" ]; then
  echo "The specified source directory does not exist."
  exit 1
fi

TIMESTAMP=$(date +"%Y%m%d%H%M%S")
BACKUP_FILE="$BACKUP_DIR/backup_$TIMESTAMP.tar.gz"

tar -czf "$BACKUP_FILE" -C "$SOURCE_DIR" .

echo "Backup has been created at $BACKUP_FILE."
